const express = require('express')
const router = express.Router()

const loginHandle = require('../router_handle/login')
const userInfoHandle = require('../router_handle/userinfo')

// 导入验证数据的中间件
const expressJoi = require('@escook/express-joi')
// 导入需要的验证规则
const { login_limit } = require('../limit/login')
const { forget_limit } = require('../limit/user')

// 注册
router.post('/register', expressJoi(login_limit), loginHandle.register)
// 登录
router.post('/login', expressJoi(login_limit), loginHandle.login)

// 忘记密码 ---- 验证账号和邮箱是否一致
router.post('/checkAccountAndEmail', userInfoHandle.checkAccountAndEmail)
// 忘记密码 --- 修改密码
router.post('/updatePasswordByAccount', expressJoi(forget_limit), userInfoHandle.updatePasswordByAccount)

// 获取信息
router.post('/getUserInfo', userInfoHandle.getUserInfo)

// 根据用户身份获取路由 
router.post('/getRouterById', loginHandle.getRouterById)

module.exports = router